Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[plugin] Fix bug related to path separator on Windows #218

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

brijeshb42
Copy link
Contributor

@brijeshb42 brijeshb42 commented Aug 30, 2024

While debugging on Windows, I found that (atleast on Windows 11), the path separator was / instead of the expected \ resulting in some files being skipped from being transformed from the node_modules.

So the fix first normalizes the path as per the platform and then checks for the transformLibraries's presence in the normalized path.

Fixes - mui/material-ui#43487

While debugging on Windows, I found that (atleast on Windows 11), the
path separator was `/` instead of the expected `\` resulting in some
files being skipped from being transformed from the `node_modules`.

So the fix first normalizes the path first as per the platform and then
checks for the `transformLibraries`'s presence in the normalized path.
@@ -132,17 +132,19 @@ export default function wywVitePlugin({
.filter((m): m is ModuleNode => !!m);
},
async transform(code, url) {
const [id] = url.split('?', 1);

const [filePath] = url.split('?', 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this arg differs from the one in the unplugin (url vs filePath)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No difference. Updated to use same names.

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works like a charm! :)

@brijeshb42 brijeshb42 merged commit 9a879c8 into mui:master Aug 30, 2024
11 of 12 checks passed
@brijeshb42 brijeshb42 deleted the vite/windows branch August 30, 2024 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants